<?php
require ("DbConnector.php");

/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ThreadDAO
 *
 * @author Administrator
 */
class ThreadDAO {
    var $dbc;
    function __construct() {
        $db = new DbConnector();
        $this->dbc = $db->getConnection();
    }

    public function getThreads($forumId) {
        mysql_select_db("messageboardot_db", $this->dbc);

        $query = "select".
        " ID, THREAD_NAME, USER_ID, FORUM_ID, FLAG, CREATION_DATE, LAST_POST_DATE" .
        " from" .
        " THREADS" .
        " where" .
        " FORUM_ID = " . $forumId;

        $result = mysql_query($query);
        $threads;
        $count = 0;

        while($row = mysql_fetch_array($result)) {
            $thread['ID'] = $row['ID'];
            $thread['THREAD_NAME'] = $row['THREAD_NAME'];
            $threads[$count] = $thread;
            $count++;
        }

        //mysql_close($this->dbc);

        return $threads;
    }
}
?>
